#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>


int main(int argc, char **argv){
    int fd;
    char status;

    if(argc !=3)
    {
        printf("usage: %s <dev> <on|off>\n, argv[0]");
    }

    fd  = open(argv[1], O_RDWR);//打开文件
    if(fd == -1){
        printf("can not open fiel %s\n", argv[1]);
    }

    if(0 == strcmp(argv[2], "on")){
        status = 1;
        write(fd, &status, 0);
    }
    else{
        status = 0;
        write(fd, &status, 1);
    }

    close(fd);
}

